import {handleActions} from "redux-actions"
import {GET_SHOPPINGSSHOP,SET_CUR_PAGESHOP,SET_EACHPAGESHOP} from "../types"
import _ from "lodash"

const initData={
    curPage: 1,
    eachPage: 10,
    total: 0,
    maxPage: 0,
    rows: []
}


export  const shoppings=handleActions({
    [GET_SHOPPINGSSHOP]:(state,{payload})=>{
        const {total,maxPage,rows}=payload
          return _.assign({},state,{
            total,maxPage,rows
          })
    },
    [SET_CUR_PAGESHOP]:(state,{payload})=>{
       const {curPage} =payload;
       const $state=_.clone(state);
       $state.curPage=curPage;
       return $state
    },
    [SET_EACHPAGESHOP]:(state,{payload})=>{
      const {eachPage}=payload
        const $state=_.clone(state)
        $state.eachPage=eachPage;
        $state.rows=[];
        return $state
   }
},initData)




